package com.lsl.musicplayer.util;

import android.content.Context;
import android.widget.Toast;

public class ToastUtil {
    private static Toast toast;

    /**
     * 短时间显示Toast
     * @param msg 显示的内容-字符串
     */
    public static void showShortToast(Context context, String msg) {
        if (toast == null) {
            toast = Toast.makeText(context, msg, Toast.LENGTH_SHORT);
        } else {
            toast.setText(msg);
        }
        toast.show();
    }

    /**
     * 短时间显示Toast
     * @param resourceId 显示的内容-资源id
     */
    public static void showShortToast(Context context,int resourceId) {
        if (toast == null) {
            toast = Toast.makeText(context, resourceId, Toast.LENGTH_SHORT);
        } else {
            toast.setText(resourceId);
        }
        toast.show();
    }




    /**
     * 长时间显示Toast
     *
     * @param msg 显示的内容-字符串
     */
    public static void showLongToast(Context context, String msg) {
        if (toast == null) {
            toast = Toast.makeText(context, msg, Toast.LENGTH_LONG);
        } else {
            toast.setText(msg);
        }
        toast.show();
    }

    /**
     * 长时间显示Toast
     *
     * @param resourceId 显示的内容-资源id
     */
    public static void showLongToast(Context context, int resourceId) {
        if (toast == null) {
            toast = Toast.makeText(context, resourceId, Toast.LENGTH_LONG);
        } else {
            toast.setText(resourceId);
        }
        toast.show();
    }

}
